package com.onpositive.wiki3.db.catmodel.matches;

import com.onpositive.wiki3.db.catmodel.Category;
import com.onpositive.wiki3.db.catmodel.ICategoryMatcher;

public class MultiLevelMatcher implements ICategoryMatcher {

	int maxLevel = 3;

	public MultiLevelMatcher(int maxLevel) {
		super();
		this.maxLevel = maxLevel;
	}

	@Override
	public int accept(Category st) {
		Category[] parents = st.getParentsCategories();
		restart:while (true) {
			for (Category z : parents) {
				for (Category q : parents) {
					if (z.id() != q.id()) {
						if (z.hasParent(q, maxLevel)) {
							st.unregisterParent(q);
							System.out.println(z+":"+q);
							parents=st.getParentsCategories();
							continue restart;
						}
					}
				}
			}
			if (true){
				break;
			}
		}
		return -1;
	}

}
